---
root: "/v5.1"
title: "KeyedEncodingContainer"
keywords: ""
layout: "default"
description: "Swift documentation for 'KeyedEncodingContainer'"
---

<div class="intro-declaration"><code class="language-swift">struct KeyedEncodingContainer</code></div><p>A concrete container that provides a view into an encoder's storage, making
the encoded properties of an encodable type accessible by keys.</p>
<table class="standard"><tr><th id="inheritance">Inheritance</th><td><code class="inherits">KeyedEncodingContainerProtocol</code></td></tr><tr><th id="aliases">Associated Types</th><td><span id="aliasesmark"></span><div class="declaration"><code class="language-swift">public typealias Key = K</code><div class="comment"></div></div></td></tr></table><div class="discussion comment"></div><h3>Initializers</h3><div id="init-00a2b987552997ee43208aca83ac6ae6" class="declaration"><a class="toggle-link" href="#comment-init-00a2b987552997ee43208aca83ac6ae6">init init(_:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init-00a2b987552997ee43208aca83ac6ae6"><p>Creates a new instance with the given container.</p>
<ul>
<li>parameter container: The container to hold.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public init&lt;Container>(_ container: Container) where K == Container.Key, Container: KeyedEncodingContainerProtocol</code></div></div><h3>Instance Variables</h3><div id="codingPath-038986a6e6564f0dd444735f926a6ca4" class="declaration"><a class="toggle-link" href="#comment-codingPath-038986a6e6564f0dd444735f926a6ca4">var codingPath</a> <span class="required">Required</span><div class="comment collapse in" id="comment-codingPath-038986a6e6564f0dd444735f926a6ca4"><p>The path of coding keys taken to get to this point in encoding.</p>
<h4>Declaration</h4><code class="language-swift">var codingPath: [CodingKey]</code></div></div><h3>Instance Methods</h3><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: Bool, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: Bool, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: String, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: String, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: Double, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: Double, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: Float, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: Float, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: Int, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: Int, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: Int8, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: Int8, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: Int16, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: Int16, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: Int32, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: Int32, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: Int64, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: Int64, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: UInt, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: UInt, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: UInt8, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: UInt8, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: UInt16, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: UInt16, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: UInt32, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: UInt32, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: UInt64, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode(_ value: UInt64, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encode_forKey-39d2a97be96fb79bdb78dc9234c0a103" class="declaration"><a class="toggle-link" href="#comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103">func encode(_ value: T, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encode_forKey-39d2a97be96fb79bdb78dc9234c0a103"><p>Encodes the given value for the given key.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encode&lt;T>(_ value: T, forKey key: KeyedEncodingContainer&lt;K>.Key) throws where T: Encodable</code></div></div><div id="encodeConditional_forKey-6fe8ea69f0777fd0a78f4ea71838fa3c" class="declaration"><a class="toggle-link" href="#comment-encodeConditional_forKey-6fe8ea69f0777fd0a78f4ea71838fa3c">func encodeConditional(_ object: T, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeConditional_forKey-6fe8ea69f0777fd0a78f4ea71838fa3c"><p>Encodes a reference to the given object only if it is encoded
unconditionally elsewhere in the payload (previously, or in the future).</p>
<p>For encoders which don't support this feature, the default implementation
encodes the given object unconditionally.</p>
<ul>
<li>parameter object: The object to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the object with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeConditional&lt;T>(_ object: T, forKey key: KeyedEncodingContainer&lt;K>.Key) throws where T: AnyObject, T: Encodable</code></div></div><div id="encodeConditional_forKey-6fe8ea69f0777fd0a78f4ea71838fa3c" class="declaration"><a class="toggle-link" href="#comment-encodeConditional_forKey-6fe8ea69f0777fd0a78f4ea71838fa3c">func encodeConditional(_ object: T, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeConditional_forKey-6fe8ea69f0777fd0a78f4ea71838fa3c"><p>Encodes a reference to the given object only if it is encoded
unconditionally elsewhere in the payload (previously, or in the future).</p>
<p>For encoders which don't support this feature, the default implementation
encodes the given object unconditionally.</p>
<ul>
<li>parameter object: The object to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the object with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeConditional&lt;T>(_ object: T, forKey key: Self.Key) throws where T: AnyObject, T: Encodable</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Bool?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Bool?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: String?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: String?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Double?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Double?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Float?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Float?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Int?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Int?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Int8?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Int8?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Int16?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Int16?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Int32?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Int32?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Int64?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Int64?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: UInt?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: UInt?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: UInt8?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: UInt8?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: UInt16?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: UInt16?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: UInt32?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: UInt32?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: UInt64?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: UInt64?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: T?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><p>Encodes the given value for the given key if it is not <code>nil</code>.</p>
<ul>
<li>parameter value: The value to encode.</li>
</ul>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent&lt;T>(_ value: T?, forKey key: KeyedEncodingContainer&lt;K>.Key) throws where T: Encodable</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Bool?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Bool?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: String?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: String?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Double?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Double?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Float?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Float?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Int?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Int?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Int8?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Int8?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Int16?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Int16?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Int32?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Int32?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: Int64?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: Int64?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: UInt?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: UInt?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: UInt8?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: UInt8?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: UInt16?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: UInt16?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: UInt32?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: UInt32?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: UInt64?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent(_ value: UInt64?, forKey key: Self.Key) throws</code></div></div><div id="encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba" class="declaration"><a class="toggle-link" href="#comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba">func encodeIfPresent(_ value: T?, forKey key: Self.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeIfPresent_forKey-ce6511231c6af60e16167569ad14aeba"><h4>Declaration</h4><code class="language-swift">public mutating func encodeIfPresent&lt;T>(_ value: T?, forKey key: Self.Key) throws where T: Encodable</code></div></div><div id="encodeNil_forKey-baa01e497c4623f8ec336ca7f43f064f" class="declaration"><a class="toggle-link" href="#comment-encodeNil_forKey-baa01e497c4623f8ec336ca7f43f064f">func encodeNil(forKey key: KeyedEncodingContainer&lt;K>.Key) throws</a> <span class="required">Required</span><div class="comment collapse in" id="comment-encodeNil_forKey-baa01e497c4623f8ec336ca7f43f064f"><p>Encodes a null value for the given key.</p>
<ul>
<li>parameter key: The key to associate the value with.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func encodeNil(forKey key: KeyedEncodingContainer&lt;K>.Key) throws</code></div></div><div id="nestedContainer_keyedBy_forKey-56d3e07ed4ef8fbfb041d378e4c8b100" class="declaration"><a class="toggle-link" href="#comment-nestedContainer_keyedBy_forKey-56d3e07ed4ef8fbfb041d378e4c8b100">func nestedContainer(keyedBy keyType: NestedKey.Type, forKey key: KeyedEncodingContainer&lt;K>.Key) -> KeyedEncodingContainer&lt;NestedKey></a> <span class="required">Required</span><div class="comment collapse in" id="comment-nestedContainer_keyedBy_forKey-56d3e07ed4ef8fbfb041d378e4c8b100"><p>Stores a keyed encoding container for the given key and returns it.</p>
<ul>
<li>parameter keyType: The key type to use for the container.</li>
</ul>
<ul>
<li>parameter key: The key to encode the container for.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func nestedContainer&lt;NestedKey>(keyedBy keyType: NestedKey.Type, forKey key: KeyedEncodingContainer&lt;K>.Key) -> KeyedEncodingContainer&lt;NestedKey> where NestedKey: CodingKey</code></div></div><div id="nestedUnkeyedContainer_forKey-a5f82c10f5abf8cf48f3881953c4ad0b" class="declaration"><a class="toggle-link" href="#comment-nestedUnkeyedContainer_forKey-a5f82c10f5abf8cf48f3881953c4ad0b">func nestedUnkeyedContainer(forKey key: KeyedEncodingContainer&lt;K>.Key) -> UnkeyedEncodingContainer</a> <span class="required">Required</span><div class="comment collapse in" id="comment-nestedUnkeyedContainer_forKey-a5f82c10f5abf8cf48f3881953c4ad0b"><p>Stores an unkeyed encoding container for the given key and returns it.</p>
<ul>
<li>parameter key: The key to encode the container for.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func nestedUnkeyedContainer(forKey key: KeyedEncodingContainer&lt;K>.Key) -> UnkeyedEncodingContainer</code></div></div><div id="superEncoder-a433614659088b611101974daaccf53a" class="declaration"><a class="toggle-link" href="#comment-superEncoder-a433614659088b611101974daaccf53a">func superEncoder() -> Encoder</a> <span class="required">Required</span><div class="comment collapse in" id="comment-superEncoder-a433614659088b611101974daaccf53a"><p>Stores a new nested container for the default <code>super</code> key and returns A
new encoder instance for encoding <code>super</code> into that container.</p>
<p>Equivalent to calling <code>superEncoder(forKey:)</code> with
<code>Key(stringValue: &quot;super&quot;, intValue: 0)</code>.</p>
<h4>Declaration</h4><code class="language-swift">public mutating func superEncoder() -> Encoder</code></div></div><div id="superEncoder_forKey-cd1a63fd1fc3edada53ad483bee23e77" class="declaration"><a class="toggle-link" href="#comment-superEncoder_forKey-cd1a63fd1fc3edada53ad483bee23e77">func superEncoder(forKey key: KeyedEncodingContainer&lt;K>.Key) -> Encoder</a> <span class="required">Required</span><div class="comment collapse in" id="comment-superEncoder_forKey-cd1a63fd1fc3edada53ad483bee23e77"><p>Stores a new nested container for the given key and returns A new encoder
instance for encoding <code>super</code> into that container.</p>
<ul>
<li>parameter key: The key to encode <code>super</code> for.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">public mutating func superEncoder(forKey key: KeyedEncodingContainer&lt;K>.Key) -> Encoder</code></div></div>